home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 29
/
Volume 29 - JOGO DISK .iso
/
Games
/
jungle_adventure.swf
/
scripts
/
__Packages
/
SSParticle.as
< prev
next >
Wrap
Text File
|
2006-11-29
|
2KB
|
78 lines
class SSParticle extends SSObject
{
var trackInSectorGrid = false;
var rogueNode = true;
var gravity = 0;
var spin = 0;
var alpha = true;
var scale = 0;
var startAlpha = 100;
function SSParticle(asset, life, velocity, rot, grav)
{
super();
this.assetID = asset;
this.lifeSpan = this.life = life;
this.velocity = !velocity ? new Vector() : velocity;
if(rot != null)
{
this.spin = rot;
}
if(grav != null)
{
this.gravity = grav;
}
}
function onRemoveFromScene()
{
this.world.removeObject(this);
}
function onAddToWorld()
{
this.addToScene();
}
function onAddToScene()
{
if(!this.target)
{
this.world.removeObject(this);
return undefined;
}
this.getUpdates();
}
function onAddTarget()
{
if(this.alpha)
{
this.target._alpha = this.startAlpha;
}
}
function update(elapsed)
{
if((this.life -= elapsed) < 0 || this.z < this.world.viewport.z + 50)
{
this.target.swapDepths(0);
this.target.removeMovieClip();
this.world.removeObject(this);
return undefined;
}
this.velocity.y += this.gravity * elapsed;
this.moveBy(this.velocity.x * elapsed,this.velocity.y * elapsed,this.velocity.z * elapsed);
}
function onDisplay(viewport, elapsed)
{
var _loc2_ = this.life / this.lifeSpan;
if(this.alpha)
{
this.target._alpha = _loc2_ * 100;
}
if(this.spin)
{
this.target._rotation += this.spin * elapsed;
}
if(this.scale)
{
this.target._xscale = this.target._yscale = this.target._xscale + (1 - _loc2_) * this.scale * (this.target._xscale / 100);
}
}
}